// 自定义测试任务定义
lazy val runFlatTest = taskKey[Unit]("Run flat FFT test")
lazy val runMixedTest = taskKey[Unit]("Run mixed FFT test")
lazy val runStreamedTest = taskKey[Unit]("Run streamed FFT test")
lazy val runNativeTest = taskKey[Unit]("Run native FFT test")
lazy val runDotTest = taskKey[Unit]("Run dot product test")

lazy val ffte = (project in file("."))
  .settings(
    name := "ffte",
    version := "1.0.0",
    scalaVersion := "2.13.14",
    // logLevel := Level.Error,
    // 新的源代码路径配置 - 彻底取消 src/main/scala
    Compile / scalaSource := baseDirectory.value / "hw" / "spinal",

    // 测试路径也迁移到 hw 下
    Test / scalaSource := baseDirectory.value / "hw" / "spinal" / "ffte" / "test",

    // 注意：SpinalHDL的输出目录在代码中配置，不在build.sbt中

    // 包含源码根目录
    Compile / unmanagedSourceDirectories += baseDirectory.value / "hw" / "spinal",
    // Compile / unmanagedSourceDirectories += baseDirectory.value / "hw" / "spinal" / "test",
    // Compile / unmanagedSourceDirectories += baseDirectory.value / "hw" / "spinal" / "ffte" / "test",
    // SpinalHDL依赖
    libraryDependencies ++= Seq(
      "com.github.spinalhdl" %% "spinalhdl-core" % "1.12.0",
      "com.github.spinalhdl" %% "spinalhdl-lib" % "1.12.0",
      compilerPlugin("com.github.spinalhdl" %% "spinalhdl-idsl-plugin" % "1.12.0"),
      // Breeze数值计算库（测试和评估需要）
      "org.scalanlp" %% "breeze" % "1.0",
      "org.scalanlp" %% "breeze-natives" % "1.0",
      "org.scalanlp" %% "breeze-viz" % "1.0"
    ),

    // 编译选项
    scalacOptions ++= Seq(
      "-deprecation",
      "-feature",
      "-unchecked",
      "-Xlint",
      "-Ywarn-value-discard"  // 警告未使用的表达式
    ),

    // 自定义测试任务实现
    runFlatTest := {
      (Compile / runMain).toTask(" ffte.test.FlatStudy").value
    },

    runMixedTest := {
      (Compile / runMain).toTask(" ffte.test.MixedStudy").value
    },

    runStreamedTest := {
      (Compile / runMain).toTask(" ffte.test.StreamedStudy").value
    },

    runNativeTest := {
      (Compile / runMain).toTask(" ffte.test.NativeStudy").value
    },

    runDotTest := {
      (Compile / runMain).toTask(" ffte.test.DotStudy").value
    },

    // 清理任务 - 包含新的目录结构
    cleanFiles += baseDirectory.value / "hw" / "gen",
    cleanFiles += baseDirectory.value / "hw" / "verilog",
    cleanFiles += baseDirectory.value / "hw" / "vhdl",
    cleanFiles += baseDirectory.value / "target",
    cleanFiles += baseDirectory.value / "simWorkspace",
    cleanFiles += baseDirectory.value / "tmp",

    fork := true
  )